package com.zggk.iroad.Distribution.distributionmx;

import android.app.Activity;
import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.zggk.iroad.api.Urls;
import com.zggk.iroad.callback.StringDialogCallback;
import com.zggk.iroad.mvp.BasePresenterImpl;

import java.util.List;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class DistributionMxPresenter extends BasePresenterImpl<DistributionMxContract.View> implements DistributionMxContract.Presenter{
    @Override
    public void testinfo(Activity activity,String RZID) {
        OkGo.<String>get(Urls.YNIP + "QueryLJCZbhmx")
                .params("BHGUID", RZID)
                .execute(new StringDialogCallback(activity) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        DistriMxBean distriMxBean = JSON.parseObject(response.body(), DistriMxBean.class);
                        if (distriMxBean.getState().equals("1")){
                            List<DistriHhMxBean> distriHhMxBeans = JSON.parseArray(distriMxBean.getBHMX(), DistriHhMxBean.class);
                            List<DistriCzBean> distriCzBeans = JSON.parseArray(distriMxBean.getCZFA(), DistriCzBean.class);
                            List<DistriZjBean> distriZjBeans = JSON.parseArray(distriMxBean.getZJJE(), DistriZjBean.class);
                            mView.getDatas(distriHhMxBeans,distriCzBeans,distriZjBeans);
                        }
                    }
                });
    }
}
